from PyQt4 import QtGui
from PyQt4.QtCore import Qt

class TartFrame(QtGui.QWidget):
        def __init__(self, *args, **kw):
		QtGui.QWidget.__init__(self, *args, **kw)
		self.setGeometry(0, 0, 218, 657)

		bg = QtGui.QLabel(self) 
		bg.setGeometry(0, 0, 218, 657)
		path = "resources/tart_frame_and_monitor.png"
		bg.setPixmap(QtGui.QPixmap(path))

                self.img_x = 206
                self.img_y = 281
		image = QtGui.QLabel(self) 
		image.setGeometry(4, 42, self.img_x, self.img_y)
		image.setAlignment(Qt.AlignVCenter|Qt.AlignHCenter)
                self.image = image

		frame = QtGui.QLabel(self) 
		frame.setGeometry(0, 28, 212, 307)
		path = "resources/tart_frame_top.png"
		frame.setPixmap(QtGui.QPixmap(path))

		text = QtGui.QLabel(self) 
		text.setGeometry(20, 367, 170, 163)
		text.setWordWrap(True)
		text.setAlignment(Qt.AlignVCenter|Qt.AlignHCenter)
		font = QtGui.QFont("White Rabbit", 12)
		text.setFont(font)
		text.setStyleSheet("color:#00a800")
		self.text = text

	def set_text(self, message):
		self.text.setText(message)

	def set_image(self, path):
		pm = QtGui.QPixmap(path)
		pms = pm.scaled(
			self.img_x,
			self.img_y,
			Qt.KeepAspectRatio,
			Qt.SmoothTransformation
		)
		self.image.setPixmap(pms)
		self.image.setAlignment(Qt.AlignVCenter|Qt.AlignHCenter)

if __name__ == "__main__":
	import sys
	from glob import glob

	app = QtGui.QApplication(sys.argv)

	font_db = QtGui.QFontDatabase()
	font_db.addApplicationFont("resources/whitrabt.ttf")

        patt = "resources/characters/Bunny Girl/*.jpg"
        patt = "resources/characters/Rebecca/*.jpg"
        patt = "resources/characters/Rachel Summers//*.jpg"
	index = 0
	ll = glob(patt)

	top = QtGui.QLabel()
	top.setGeometry(0, 0, 324, 700)
	path = "resources/wood.jpg"
	top.setPixmap(QtGui.QPixmap(path))

	screen = TartFrame(top)
	screen.move(50,50)
	screen.set_text(
		"The daughter of Jean Grey.  A former member of Excalibur.."
		"\n\n"
		"She is has no strong feelings for you in any way."
	)
	screen.set_image(ll[index])

	def next_cb():
		global index

		index += 1
		if index >= len(ll):
			index = 0
		screen.set_image(ll[index])

	next = QtGui.QPushButton(top)
	next.setText("Next")
	next.clicked.connect(next_cb)
	next.move(120,650)


	top.show()
	sys.exit(app.exec_())


